{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import tensorflow as tf\n",
    "from tensorflow import keras"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "outputs": [],
   "source": [
    "def get_model():\n",
    "    model = keras.Sequential()\n",
    "    model.add(keras.layers.Dense(1,input_dim=784))\n",
    "    model.compile(\n",
    "        optimizer=keras.optimizers.RMSprop(learning_rate=0.1),\n",
    "        loss='mean_squared_error',\n",
    "        metrics=['mean_absolute_error']\n",
    "    )\n",
    "    return model\n",
    "(x_train,y_train),(x_test,y_test) = tf.keras.datasets.mnist.load_data()\n",
    "x_train = x_train.reshape(-1,784).astype(\"float32\") / 255.0\n",
    "x_test = x_test.reshape(-1,784).astype('float32') / 255.0\n",
    "\n",
    "x_train = x_train[:1000]\n",
    "y_train = y_train[:1000]\n",
    "x_test = x_test[:1000]\n",
    "y_test = y_test[:1000]\n"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "outputs": [],
   "source": [
    "class CustomCallback(keras.callbacks.Callback):\n",
    "    def on_train_begin(self, logs=None):\n",
    "        keys = list(logs.keys())\n",
    "        print(\"Strating training;got log keys:{}\".format(keys))\n",
    "\n",
    "    def on_train_end(self,logs=None):\n",
    "        keys = list(logs.keys())\n",
    "        print(\"Stop training;got log keys:{}\".format(keys))\n",
    "\n",
    "    def on_epoch_begin(self, epoch, logs=None):\n",
    "        keys = list(logs.keys())\n",
    "        print(\"Start epoch {} of training;got log keys:{}\".format(epoch,keys))\n",
    "\n",
    "    def on_epoch_end(self, epoch, logs=None):\n",
    "        keys = list(logs.keys())\n",
    "        print(\"End epoch {} of training;got log keys:{}\".format(epoch,keys))\n",
    "\n",
    "    def on_test_begin(self,logs=None):\n",
    "        keys = list(logs.keys())\n",
    "        print(\"Start testing;got log keys:{}\".format(keys))\n",
    "\n",
    "    def on_test_end(self,logs=None):\n",
    "        keys = list(logs.keys())\n",
    "        print('Stop testing;got log keys：{}'.format(keys))\n",
    "\n",
    "    def on_predict_begin(self,logs=None):\n",
    "        keys = list(logs.keys())\n",
    "        print(\"start predicting;got log keys:{}\".format(keys))\n",
    "\n",
    "    def on_predict_end(self,logs=None):\n",
    "        keys = list(logs.keys())\n",
    "        print(\"stop predicting;got log keys:{}\".format(keys))\n",
    "\n",
    "    def on_train_batch_begin(self, batch, logs=None):\n",
    "        keys = list(logs.keys())\n",
    "        print(\"...Training:start of batch {}; got log keys:{}\".format(batch,keys))\n",
    "\n",
    "    def on_train_batch_end(self, batch, logs=None):\n",
    "        keys = list(logs.keys())\n",
    "        print(\"...Training:end of batch {};got log keys:{}\".format(batch,keys))\n",
    "\n",
    "    def on_test_batch_begin(self, batch, logs=None):\n",
    "        keys = list(logs.keys())\n",
    "        print(\"...Evaluating:start of batch {}; got log keys:{}\".format(batch,keys))\n",
    "\n",
    "    def on_test_batch_end(self, batch, logs=None):\n",
    "        keys = list(logs.keys())\n",
    "        print(\"...Evaluating:end of batch {};got log keys:{}\".format(batch,keys))\n",
    "\n",
    "    def on_predict_batch_begin(self, batch, logs=None):\n",
    "        keys = list(logs.keys())\n",
    "        print(\"...PredictingLstart of batch {};got log keys:{}\".format(batch,keys))\n",
    "\n",
    "    def on_predict_batch_end(self, batch, logs=None):\n",
    "        keys = list(logs.keys())\n",
    "        print(\"...Predicting: end of batch {};got log keys:{}\".format(batch,keys))\n"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Strating training;got log keys:[]\n",
      "Start epoch 0 of training;got log keys:[]\n",
      "...Training:start of batch 0; got log keys:[]\n",
      "...Training:end of batch 0;got log keys:['loss', 'mean_absolute_error']\n",
      "...Training:start of batch 1; got log keys:[]\n",
      "...Training:end of batch 1;got log keys:['loss', 'mean_absolute_error']\n",
      "...Training:start of batch 2; got log keys:[]\n",
      "...Training:end of batch 2;got log keys:['loss', 'mean_absolute_error']\n",
      "...Training:start of batch 3; got log keys:[]\n",
      "...Training:end of batch 3;got log keys:['loss', 'mean_absolute_error']\n",
      "Start testing;got log keys:[]\n",
      "...Evaluating:start of batch 0; got log keys:[]\n",
      "...Evaluating:end of batch 0;got log keys:['loss', 'mean_absolute_error']\n",
      "...Evaluating:start of batch 1; got log keys:[]\n",
      "...Evaluating:end of batch 1;got log keys:['loss', 'mean_absolute_error']\n",
      "...Evaluating:start of batch 2; got log keys:[]\n",
      "...Evaluating:end of batch 2;got log keys:['loss', 'mean_absolute_error']\n",
      "...Evaluating:start of batch 3; got log keys:[]\n",
      "...Evaluating:end of batch 3;got log keys:['loss', 'mean_absolute_error']\n",
      "Stop testing;got log keys：[]\n",
      "End epoch 0 of training;got log keys:['loss', 'mean_absolute_error', 'val_loss', 'val_mean_absolute_error']\n",
      "Stop training;got log keys:[]\n",
      "Start testing;got log keys:[]\n",
      "...Evaluating:start of batch 0; got log keys:[]\n",
      "...Evaluating:end of batch 0;got log keys:['loss', 'mean_absolute_error']\n",
      "...Evaluating:start of batch 1; got log keys:[]\n",
      "...Evaluating:end of batch 1;got log keys:['loss', 'mean_absolute_error']\n",
      "...Evaluating:start of batch 2; got log keys:[]\n",
      "...Evaluating:end of batch 2;got log keys:['loss', 'mean_absolute_error']\n",
      "...Evaluating:start of batch 3; got log keys:[]\n",
      "...Evaluating:end of batch 3;got log keys:['loss', 'mean_absolute_error']\n",
      "...Evaluating:start of batch 4; got log keys:[]\n",
      "...Evaluating:end of batch 4;got log keys:['loss', 'mean_absolute_error']\n",
      "...Evaluating:start of batch 5; got log keys:[]\n",
      "...Evaluating:end of batch 5;got log keys:['loss', 'mean_absolute_error']\n",
      "...Evaluating:start of batch 6; got log keys:[]\n",
      "...Evaluating:end of batch 6;got log keys:['loss', 'mean_absolute_error']\n",
      "...Evaluating:start of batch 7; got log keys:[]\n",
      "...Evaluating:end of batch 7;got log keys:['loss', 'mean_absolute_error']\n",
      "Stop testing;got log keys：[]\n",
      "start predicting;got log keys:[]\n",
      "...PredictingLstart of batch 0;got log keys:[]\n",
      "...Predicting: end of batch 0;got log keys:['outputs']\n",
      "...PredictingLstart of batch 1;got log keys:[]\n",
      "...Predicting: end of batch 1;got log keys:['outputs']\n",
      "...PredictingLstart of batch 2;got log keys:[]\n",
      "...Predicting: end of batch 2;got log keys:['outputs']\n",
      "...PredictingLstart of batch 3;got log keys:[]\n",
      "...Predicting: end of batch 3;got log keys:['outputs']\n",
      "...PredictingLstart of batch 4;got log keys:[]\n",
      "...Predicting: end of batch 4;got log keys:['outputs']\n",
      "...PredictingLstart of batch 5;got log keys:[]\n",
      "...Predicting: end of batch 5;got log keys:['outputs']\n",
      "...PredictingLstart of batch 6;got log keys:[]\n",
      "...Predicting: end of batch 6;got log keys:['outputs']\n",
      "...PredictingLstart of batch 7;got log keys:[]\n",
      "...Predicting: end of batch 7;got log keys:['outputs']\n",
      "stop predicting;got log keys:[]\n"
     ]
    }
   ],
   "source": [
    "model = get_model()\n",
    "model.fit(\n",
    "    x_train,\n",
    "    y_train,\n",
    "    batch_size=128,\n",
    "    epochs=1,\n",
    "    verbose=0,\n",
    "    validation_split=0.5,\n",
    "    callbacks=[CustomCallback()],\n",
    ")\n",
    "\n",
    "res = model.evaluate(\n",
    "    x_test,y_test,batch_size=128,verbose=0,callbacks=[\n",
    "        CustomCallback()\n",
    "    ]\n",
    ")\n",
    "\n",
    "res = model.predict(x_test,batch_size=128,callbacks=[\n",
    "    CustomCallback()\n",
    "])\n",
    "\n",
    "\n"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "For batch 0,loss is   29.46.\n",
      "For batch 1,loss is  419.96.\n",
      "For batch 2,loss is  288.48.\n",
      "For batch 3,loss is  218.88.\n",
      "For batch 4,loss is  176.39.\n",
      "For batch 5,loss is  148.01.\n",
      "For batch 6,loss is  127.69.\n",
      "For batch 7,loss is  115.06.\n",
      "The average loss for epoch 0 is  115.06and mean absolute error is    5.88.\n",
      "For batch 0,loss is    5.07.\n",
      "For batch 1,loss is    5.24.\n",
      "For batch 2,loss is    5.04.\n",
      "For batch 3,loss is    4.78.\n",
      "For batch 4,loss is    4.62.\n",
      "For batch 5,loss is    4.71.\n",
      "For batch 6,loss is    4.79.\n",
      "For batch 7,loss is    4.91.\n",
      "The average loss for epoch 1 is    4.91and mean absolute error is    1.78.\n",
      "For batch 0,loss is   11.59.\n",
      "For batch 1,loss is   10.35.\n",
      "For batch 2,loss is   10.84.\n",
      "For batch 3,loss is   11.00.\n",
      "For batch 4,loss is   11.39.\n",
      "For batch 5,loss is   11.27.\n",
      "For batch 6,loss is   11.27.\n",
      "For batch 7,loss is   11.21.\n"
     ]
    }
   ],
   "source": [
    "class LossAndErrorPrintingCallback(keras.callbacks.Callback):\n",
    "    def on_train_batch_end(self, batch, logs=None):\n",
    "        print(\"For batch {},loss is {:7.2f}.\".format(batch,logs['loss']))\n",
    "\n",
    "    def on_test_batch_end(self, batch, logs=None):\n",
    "        print(\"For batch {},loss is {:7.2f}.\".format(batch,logs['loss']))\n",
    "\n",
    "    def on_epoch_end(self, epoch, logs=None):\n",
    "        print(\"The average loss for epoch {} is {:7.2f}\"\n",
    "              \"and mean absolute error is {:7.2f}.\".format(\n",
    "            epoch,logs['loss'],logs['mean_absolute_error']\n",
    "              ))\n",
    "\n",
    "model = get_model()\n",
    "model.fit(\n",
    "    x_train,\n",
    "    y_train,\n",
    "    batch_size = 128,\n",
    "    epochs=2,\n",
    "    verbose=0,\n",
    "    callbacks=[LossAndErrorPrintingCallback()]\n",
    "\n",
    ")\n",
    "\n",
    "res = model.evaluate(\n",
    "    x_test,\n",
    "    y_test,\n",
    "    batch_size=128,\n",
    "    verbose=0,\n",
    "    callbacks=[LossAndErrorPrintingCallback()],\n",
    ")\n"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "For batch 0,loss is   28.87.\n",
      "For batch 1,loss is  513.04.\n",
      "For batch 2,loss is  351.31.\n",
      "For batch 3,loss is  265.63.\n",
      "For batch 4,loss is  214.16.\n",
      "The average loss for epoch 0 is  214.16and mean absolute error is    8.65.\n",
      "For batch 0,loss is    7.24.\n",
      "For batch 1,loss is    7.16.\n",
      "For batch 2,loss is    6.62.\n",
      "For batch 3,loss is    6.20.\n",
      "For batch 4,loss is    5.92.\n",
      "The average loss for epoch 1 is    5.92and mean absolute error is    2.01.\n",
      "For batch 0,loss is    6.01.\n",
      "For batch 1,loss is    5.60.\n",
      "For batch 2,loss is    5.02.\n",
      "For batch 3,loss is    5.06.\n",
      "For batch 4,loss is    5.40.\n",
      "The average loss for epoch 2 is    5.40and mean absolute error is    1.90.\n",
      "For batch 0,loss is    6.97.\n",
      "For batch 1,loss is    6.18.\n",
      "For batch 2,loss is    7.70.\n",
      "For batch 3,loss is   11.22.\n",
      "For batch 4,loss is   14.91.\n",
      "The average loss for epoch 3 is   14.91and mean absolute error is    3.16.\n",
      "Restoring model weights from the end of the best epoch\n",
      "Epoch 00004:early stopping\n"
     ]
    },
    {
     "data": {
      "text/plain": "<tensorflow.python.keras.callbacks.History at 0x195d7d7d688>"
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import numpy as np\n",
    "class EarlyStoppingAtMinLoss(keras.callbacks.Callback):\n",
    "    def __init__(self,patience=0):\n",
    "        super(EarlyStoppingAtMinLoss,self).__init__()\n",
    "        self.patience = patience\n",
    "        self.best_weights = None\n",
    "\n",
    "    def on_train_begin(self,logs=None):\n",
    "        self.wait = 0\n",
    "        self.stopped_epoch = 0\n",
    "        self.best = np.Inf\n",
    "\n",
    "    def on_epoch_end(self, epoch, logs=None):\n",
    "        current = logs.get(\"loss\")\n",
    "        if np.less(current,self.best):\n",
    "            self.best = current\n",
    "            self.wait = 0\n",
    "            self.best_weights = self.model.get_weights()\n",
    "        else:\n",
    "            self.wait += 1\n",
    "            if self.wait >= self.patience:\n",
    "                self.stopped_epoch = epoch\n",
    "                self.model.stop_training = True\n",
    "                print(\"Restoring model weights from the end of the best epoch\")\n",
    "                self.model.set_weights(self.best_weights)\n",
    "\n",
    "    def on_train_end(self,logs= None):\n",
    "        if self.stopped_epoch > 0:\n",
    "            print(\"Epoch %05d:early stopping\" % (self.stopped_epoch + 1))\n",
    "\n",
    "model = get_model()\n",
    "model.fit(\n",
    "    x_train,\n",
    "    y_train,\n",
    "    batch_size=64,\n",
    "    steps_per_epoch=5,\n",
    "    epochs=30,\n",
    "    verbose=0,\n",
    "    callbacks=[\n",
    "        LossAndErrorPrintingCallback(),\n",
    "        EarlyStoppingAtMinLoss()\n",
    "    ]\n",
    ")"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Epoch 00000: Learning rate is 0.1000.\n",
      "For batch 0,loss is   32.82.\n",
      "For batch 1,loss is  526.11.\n",
      "For batch 2,loss is  358.90.\n",
      "For batch 3,loss is  270.75.\n",
      "For batch 4,loss is  217.81.\n",
      "The average loss for epoch 0 is  217.81and mean absolute error is    8.58.\n",
      "\n",
      "Epoch 00001: Learning rate is 0.1000.\n",
      "For batch 0,loss is    6.38.\n",
      "For batch 1,loss is    6.45.\n",
      "For batch 2,loss is    6.07.\n",
      "For batch 3,loss is    5.90.\n",
      "For batch 4,loss is    6.16.\n",
      "The average loss for epoch 1 is    6.16and mean absolute error is    2.08.\n",
      "\n",
      "Epoch 00002: Learning rate is 0.1000.\n",
      "For batch 0,loss is    4.33.\n",
      "For batch 1,loss is    4.57.\n",
      "For batch 2,loss is    4.69.\n",
      "For batch 3,loss is    4.81.\n",
      "For batch 4,loss is    4.77.\n",
      "The average loss for epoch 2 is    4.77and mean absolute error is    1.77.\n",
      "\n",
      "Epoch 00003: Learning rate is 0.0500.\n",
      "For batch 0,loss is    6.04.\n",
      "For batch 1,loss is    4.69.\n",
      "For batch 2,loss is    4.10.\n",
      "For batch 3,loss is    4.12.\n",
      "For batch 4,loss is    4.23.\n",
      "The average loss for epoch 3 is    4.23and mean absolute error is    1.60.\n",
      "\n",
      "Epoch 00004: Learning rate is 0.0500.\n",
      "For batch 0,loss is    4.83.\n",
      "For batch 1,loss is    4.98.\n",
      "For batch 2,loss is    4.82.\n",
      "For batch 3,loss is    4.85.\n",
      "For batch 4,loss is    4.62.\n",
      "The average loss for epoch 4 is    4.62and mean absolute error is    1.74.\n",
      "\n",
      "Epoch 00005: Learning rate is 0.0500.\n",
      "For batch 0,loss is    3.94.\n",
      "For batch 1,loss is    3.96.\n",
      "For batch 2,loss is    4.42.\n",
      "For batch 3,loss is    4.18.\n",
      "For batch 4,loss is    4.01.\n",
      "The average loss for epoch 5 is    4.01and mean absolute error is    1.56.\n",
      "\n",
      "Epoch 00006: Learning rate is 0.0100.\n",
      "For batch 0,loss is    3.02.\n",
      "For batch 1,loss is    3.53.\n",
      "For batch 2,loss is    3.46.\n",
      "For batch 3,loss is    3.42.\n",
      "For batch 4,loss is    3.28.\n",
      "The average loss for epoch 6 is    3.28and mean absolute error is    1.43.\n",
      "\n",
      "Epoch 00007: Learning rate is 0.0100.\n",
      "For batch 0,loss is    3.92.\n",
      "For batch 1,loss is    3.60.\n",
      "For batch 2,loss is    3.55.\n",
      "For batch 3,loss is    3.50.\n",
      "For batch 4,loss is    3.29.\n",
      "The average loss for epoch 7 is    3.29and mean absolute error is    1.43.\n",
      "\n",
      "Epoch 00008: Learning rate is 0.0100.\n",
      "For batch 0,loss is    3.41.\n",
      "For batch 1,loss is    3.63.\n",
      "For batch 2,loss is    3.55.\n",
      "For batch 3,loss is    3.38.\n",
      "For batch 4,loss is    3.41.\n",
      "The average loss for epoch 8 is    3.41and mean absolute error is    1.46.\n",
      "\n",
      "Epoch 00009: Learning rate is 0.0050.\n",
      "For batch 0,loss is    3.06.\n",
      "For batch 1,loss is    3.65.\n",
      "For batch 2,loss is    3.82.\n",
      "For batch 3,loss is    3.69.\n",
      "For batch 4,loss is    3.40.\n",
      "The average loss for epoch 9 is    3.40and mean absolute error is    1.40.\n",
      "\n",
      "Epoch 00010: Learning rate is 0.0050.\n",
      "For batch 0,loss is    2.79.\n",
      "For batch 1,loss is    3.04.\n",
      "For batch 2,loss is    3.18.\n",
      "For batch 3,loss is    3.14.\n",
      "For batch 4,loss is    3.17.\n",
      "The average loss for epoch 10 is    3.17and mean absolute error is    1.38.\n",
      "\n",
      "Epoch 00011: Learning rate is 0.0050.\n",
      "For batch 0,loss is    2.56.\n",
      "For batch 1,loss is    3.06.\n",
      "For batch 2,loss is    3.08.\n",
      "For batch 3,loss is    2.96.\n",
      "For batch 4,loss is    3.27.\n",
      "The average loss for epoch 11 is    3.27and mean absolute error is    1.44.\n",
      "\n",
      "Epoch 00012: Learning rate is 0.0010.\n",
      "For batch 0,loss is    3.30.\n",
      "For batch 1,loss is    3.18.\n",
      "For batch 2,loss is    3.23.\n",
      "For batch 3,loss is    3.68.\n",
      "For batch 4,loss is    3.43.\n",
      "The average loss for epoch 12 is    3.43and mean absolute error is    1.41.\n",
      "\n",
      "Epoch 00013: Learning rate is 0.0010.\n",
      "For batch 0,loss is    3.23.\n",
      "For batch 1,loss is    3.40.\n",
      "For batch 2,loss is    3.05.\n",
      "For batch 3,loss is    2.94.\n",
      "For batch 4,loss is    2.97.\n",
      "The average loss for epoch 13 is    2.97and mean absolute error is    1.35.\n",
      "\n",
      "Epoch 00014: Learning rate is 0.0010.\n",
      "For batch 0,loss is    3.76.\n",
      "For batch 1,loss is    3.57.\n",
      "For batch 2,loss is    3.15.\n",
      "For batch 3,loss is    3.39.\n",
      "For batch 4,loss is    3.51.\n",
      "The average loss for epoch 14 is    3.51and mean absolute error is    1.44.\n"
     ]
    },
    {
     "data": {
      "text/plain": "<tensorflow.python.keras.callbacks.History at 0x195c1c25148>"
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "class CustomLearningRateScheduler(keras.callbacks.Callback):\n",
    "    def __init__(self,schedule):\n",
    "        super(CustomLearningRateScheduler,self).__init__()\n",
    "        self.schedule = schedule\n",
    "\n",
    "    def on_epoch_begin(self, epoch, logs=None):\n",
    "        if not hasattr(self.model.optimizer,'lr'):\n",
    "            raise ValueError(\"Optimizer must have a 'lr' attribute.\")\n",
    "\n",
    "        lr = float(tf.keras.backend.get_value(self.model.optimizer.learning_rate))\n",
    "        scheduled_lr = self.schedule(epoch,lr)\n",
    "        tf.keras.backend.set_value(self.model.optimizer.lr,scheduled_lr)\n",
    "        print(\"\\nEpoch %05d: Learning rate is %6.4f.\" % (epoch, scheduled_lr))\n",
    "\n",
    "LR_SCHEDULE = [\n",
    "    (3,0.05),\n",
    "    (6,0.01),\n",
    "    (9,0.005),\n",
    "    (12,0.001)\n",
    "]\n",
    "\n",
    "def lr_schedule(epoch,lr):\n",
    "    if epoch < LR_SCHEDULE[0][0] or epoch > LR_SCHEDULE[-1][0]:\n",
    "        return lr\n",
    "    for i in range(len(LR_SCHEDULE)):\n",
    "        if epoch == LR_SCHEDULE[i][0]:\n",
    "            return LR_SCHEDULE[i][1]\n",
    "    return lr\n",
    "\n",
    "model = get_model()\n",
    "model.fit(\n",
    "    x_train,\n",
    "    y_train,\n",
    "    batch_size=64,\n",
    "    steps_per_epoch=5,\n",
    "    epochs=15,\n",
    "    verbose=0,\n",
    "    callbacks=[\n",
    "        LossAndErrorPrintingCallback(),\n",
    "        CustomLearningRateScheduler(lr_schedule),\n",
    "    ]\n",
    ")\n",
    "\n"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}